package com.yanxml.spi.java.showcase;

import com.yanxml.spi.java.common.Connection;
import com.yanxml.spi.java.mysql.MySqlConnection;
import com.yanxml.spi.java.oracle.OracleConnection;

import java.util.Iterator;
import java.util.ServiceLoader;

public class DemoShowCase {

    /**
     * SPI
     */
    public static void main(String[] args) {
        ServiceLoader<Connection> loader = ServiceLoader.load(Connection.class);
        // Java原生的SPI较为繁琐, 只能通过迭代器进行获取.
        Iterator<Connection> iterator = loader.iterator();
        while (iterator.hasNext()) {
            Connection connection = iterator.next();
            connection.getUrl();
        }

//        new MySqlConnection().getUrl();
//        new OracleConnection().getUrl();

    }
}

// show demo
//Mysql Connection Start ---------
//Oracle Connection Start ---------